package edge.display.backend.MsgHandler;

import com.alibaba.fastjson.JSONObject;
import edge.display.backend.KEY_STORE;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * 初始化类数据处理中心
 *
 * @author Amane Hayashi
 * @date 2020/10/24
 * @since 1.0
 */

@Component
public class RespHandler {

    static int[] tasksExecuted;
    static int[] tasksComing;

    static {
        int nodesNumber = KEY_STORE.NODE_MAP.size();
        tasksExecuted = new int[nodesNumber];
        tasksComing = new int[nodesNumber];
    }

    // (frontend -> backend) -> frontend
    public static JSONObject onHello(JSONObject jsonObject) {
        return new JSONObject(new HashMap<String, Object>() {
            {
                put(KEY_STORE.JSON_KEY, jsonObject.getString(KEY_STORE.JSON_KEY));
            }
        });
    }
}
